import { ApiPropertyOptional } from '@nestjs/swagger';
import { BasePaginationDto } from '@nbase/nest-mods';
import { IsOptional, IsString, IsInt, IsDateString } from 'class-validator';
import { Type } from 'class-transformer';
import { IQueryAuditLog } from '@nbase/shared';

/**
 * 查询审计日志 DTO
 */
export class QueryAuditLogDto extends BasePaginationDto implements IQueryAuditLog {
  @ApiPropertyOptional({
    description: '用户名关键词',
    example: 'admin',
  })
  @IsOptional()
  @IsString()
  username?: string;

  @ApiPropertyOptional({
    description: '操作模块关键词',
    example: '用户管理',
  })
  @IsOptional()
  @IsString()
  module?: string;

  @ApiPropertyOptional({
    description: '操作类型（1.查询 2.新增 3.修改 4.删除 5.导出 6.导入 7.登录 8.登出 9.其他）',
    example: 2,
  })
  @IsOptional()
  @Type(() => Number)
  @IsInt()
  operationType?: number;

  @ApiPropertyOptional({
    description: '请求方法',
    example: 'POST',
  })
  @IsOptional()
  @IsString()
  method?: string;

  @ApiPropertyOptional({
    description: '请求路径关键词',
    example: '/api/user',
  })
  @IsOptional()
  @IsString()
  path?: string;

  @ApiPropertyOptional({
    description: 'IP地址关键词',
    example: '192.168',
  })
  @IsOptional()
  @IsString()
  ip?: string;

  @ApiPropertyOptional({
    description: '开始日期',
    example: '2024-01-01',
  })
  @IsOptional()
  @IsDateString()
  startDate?: string;

  @ApiPropertyOptional({
    description: '结束日期',
    example: '2024-12-31',
  })
  @IsOptional()
  @IsDateString()
  endDate?: string;
}

